home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / diskfree / diskfree.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  3.6 KB  |  117 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Disk Spaces DLL Demo"
  6.    ClientHeight    =   2505
  7.    ClientLeft      =   2160
  8.    ClientTop       =   1845
  9.    ClientWidth     =   4530
  10.    ControlBox      =   0   'False
  11.    Height          =   2910
  12.    Left            =   2100
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2505
  17.    ScaleWidth      =   4530
  18.    Top             =   1500
  19.    Width           =   4650
  20.    Begin CommandButton Command1 
  21.       Caption         =   "&OK"
  22.       Height          =   525
  23.       Left            =   3510
  24.       TabIndex        =   6
  25.       Top             =   1890
  26.       Width           =   945
  27.    End
  28.    Begin DriveListBox Drive1 
  29.       BackColor       =   &H00FFFFFF&
  30.       Height          =   315
  31.       Left            =   750
  32.       TabIndex        =   4
  33.       Top             =   1260
  34.       Width           =   2415
  35.    End
  36.    Begin Label Label6 
  37.       BackColor       =   &H00C0C0C0&
  38.       Caption         =   "Demo by John Castravet"
  39.       Height          =   195
  40.       Left            =   1260
  41.       TabIndex        =   7
  42.       Top             =   90
  43.       Width           =   2145
  44.    End
  45.    Begin Label Label5 
  46.       BackColor       =   &H00C0C0C0&
  47.       Caption         =   "Drive:"
  48.       Height          =   195
  49.       Left            =   60
  50.       TabIndex        =   5
  51.       Top             =   1320
  52.       Width           =   675
  53.    End
  54.    Begin Label Label4 
  55.       BorderStyle     =   1  'Fixed Single
  56.       Height          =   255
  57.       Left            =   1290
  58.       TabIndex        =   3
  59.       Top             =   720
  60.       Width           =   1875
  61.    End
  62.    Begin Label Label3 
  63.       BackColor       =   &H00C0C0C0&
  64.       Caption         =   "Free Space:"
  65.       Height          =   195
  66.       Left            =   60
  67.       TabIndex        =   2
  68.       Top             =   750
  69.       Width           =   1185
  70.    End
  71.    Begin Label Label2 
  72.       BorderStyle     =   1  'Fixed Single
  73.       Height          =   255
  74.       Left            =   1290
  75.       TabIndex        =   1
  76.       Top             =   390
  77.       Width           =   1875
  78.    End
  79.    Begin Label Label1 
  80.       BackColor       =   &H00C0C0C0&
  81.       Caption         =   "Total Space:"
  82.       Height          =   195
  83.       Left            =   60
  84.       TabIndex        =   0
  85.       Top             =   420
  86.       Width           =   1185
  87.    End
  88. Sub Command1_Click ()
  89.   Unload Form1
  90. End Sub
  91. Sub Drive1_Change ()
  92.   'The Total and the Available disk spaces are shown in Label2 and Label4.
  93.   'If interested you can also use the Bytes Per Sector, Sectors Per Cluster,
  94.   'the total Disk Clusters and the available Disk Clusters.
  95.   'Use the Panel control found in THREED.VBX with the Flood property set
  96.   'to create a bar graph type indicator.
  97.   Dim DiskSpace As DiskFree
  98.   Dim Unit As Integer
  99.   Dim dBytesCluster As Double
  100.   Dim dTemp As Double
  101.   Unit = Asc(Drive1.Drive) - Asc("a") + 1
  102.   Er% = GetDiskSpaces(Unit, DiskSpace)
  103.   If Er% = 0 Then
  104.     dBytesCluster = DiskSpace.Bytes_Per_Sector * DiskSpace.Sectors_Per_Cluster
  105.     dTemp = dBytesCluster * DiskSpace.Total_Clusters
  106.     Label2.Caption = Format$(dTemp / 1024, "#,##0 KB")
  107.     dTemp = dBytesCluster * DiskSpace.Avail_Clusters
  108.     Label4.Caption = Format$(dTemp / 1024, "#,##0 KB")
  109.   Else
  110.     Label2.Caption = "Disk Error"
  111.     Label4.Caption = "Disk Error"
  112.   End If
  113. End Sub
  114. Sub Form_Load ()
  115.   Drive1_Change
  116. End Sub
  117.